﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.BaseDoc.Model;

public partial class Task_DocumentUpType : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();
    }
    private void Bind()
    {
        dptParent.Items.Clear();
        string DepartmentID = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).DepartmentID;
        List<Yipusoft.BaseDoc.Model.DocumentFileInfo> list = Yipusoft.BaseDoc.BLL.FileManager.GetList(" IsFolder='True'  And ParentID='" + Guid.Empty + "' Order by OrderID ");
        foreach (DocumentFileInfo file in list)
        {
            dptParent.Items.Add(new ListItem("".PadLeft(2 * file.Level.Value, '　') + file.OldFileName, file.ID.ToString()));
            OrderItem(file.ID, file.OldFileName);



        }
        //dptParent.Items.Insert(0, new ListItem("顶级分类", "00"));
    }

    private void OrderItem(Guid ID, string oldFileName)
    {
        List<Yipusoft.BaseDoc.Model.DocumentFileInfo> list = Yipusoft.BaseDoc.BLL.FileManager.GetList(" IsFolder='True'  And ParentID='" + ID + "' Order by OrderID ");
        if (list != null)
        {
            foreach (DocumentFileInfo info in list)
            {
                dptParent.Items.Add(new ListItem("".PadLeft(2 * info.Level.Value, '　') + info.OldFileName, info.ID.ToString()));
                OrderItem(info.ID, info.OldFileName);
            }
        }

    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        Response.Redirect("UploadFile.aspx?LogId=" + Request.QueryString["LogId"] + "&Flag=Log&Type="+dptParent.SelectedValue);
        //RootId=346&UserId=1301010&LogId=932
        //UploadFile.aspx?LogId=932&Flag=Log
    }
}
